isImportantForAutofill

Hints the Android System whether the android.app.assist.AssistStructure.ViewNode associated with this view is considered important for autofill purposes.

Generally speaking, a view is important for autofill if:

  1. The view can be autofilled by an android.service.autofill.AutofillService.
  2. The view contents can help an android.service.autofill.AutofillService determine how other views can be autofilled.

For example, view containers should typically return false for performance reasons (since the important info is provided by their children), but if its properties have relevant information (for example, a resource id called credentials, it should return true. On the other hand, views representing labels or editable fields should typically return true, but in some cases they could return false (for example, if they're part of a "Captcha" mechanism).

The value returned by this method depends on the value returned by getImportantForAutofill:

  1. if it returns IMPORTANT_FOR_AUTOFILL_YES or IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS, then it returns true
  2. if it returns IMPORTANT_FOR_AUTOFILL_NO or IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS, then it returns false
  3. if it returns IMPORTANT_FOR_AUTOFILL_AUTO, then it uses some simple heuristics that can return true in some cases (like a container with a resource id), but false in most.
  4. otherwise, it returns false.

When a view is considered important for autofill:

  • The view might automatically trigger an autofill request when focused on.
  • The contents of the view are included in the android.view.ViewStructure used in an autofill request.

On the other hand, when a view is considered not important for autofill:

This method is only supported on API >= 26. On API 25 and below, it will always return true.

Return

whether the view is considered important for autofill.

Parameters

v

The View against which to invoke the method.

See also